//
//  ViewController.swift
//  GlobalTimer
//
//  Created by XFNicar on 11/04/2021.
//  Copyright (c) 2021 XFNicar. All rights reserved.
//

import UIKit
import GlobalTimer

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        GlobalTimer.timer.add("viewcontroller") { [weak self ](time) in
            if time % 30 == 0 {
                print("计时器\(time)")
            }
        }
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        GlobalTimer.timer.remove("viewcontroller")
    }
    
    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

